package ari.com.eft.jobs;

import java.io.FileNotFoundException;
import java.io.IOException;

import ari.com.eft.utils.SessionManagerProperties;
import ari.com.eft.utils.SessionManagerPropertiesImpl;

import com.ari.eft.transport.tls.EPPTLSTransport;
import com.ari.eft.transport.tls.SessionConfigurationException;
import com.ari.eft.transport.tls.SessionProperties;
import com.ari.eft.transport.tls.TLSSession;

/* Name does not sound alright. Think of a better name */

public class EFTTransportMgr {

	private static TLSSession session = null;

	/* TODO change this to a new interface */
	public static EPPTLSTransport getEPPTransportInstance()
			throws SessionConfigurationException {
		if (session == null) {
			session = (TLSSession) createTransportInstance();
		}
		return session;
	}

	/* TODO change this to a new interface */
	public static EPPTLSTransport createTransportInstance()
			throws SessionConfigurationException {
		SessionManagerProperties sessionMgrProps = null;
		try {
			sessionMgrProps = new SessionManagerPropertiesImpl(
					"toolkit.properties");
		} catch (final FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (final IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		final SessionProperties sessionProps = sessionMgrProps
				.getSessionProperties();
		if (session == null) {
			session = new TLSSession(sessionProps);
		}
		return session;
	}

}
